local skel = fk.CreateSkill {
  name = "emo__shenyong",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__shenyong"] = "深泳",
  [":emo__shenyong"] = "锁定技，游戏开始时，你令一名其他角色获得锁定技“天命”。当你弃置两张同色牌时，你视为使用一张冰【杀】，若未造成伤害你失去一点体力。",

  ["#emo__shenyong-choose"] = "深泳:令一名其他角色获得锁定技“天命”",
  ["#emo__shenyong-slash"] = "深泳:使用一张冰【杀】，若未造成伤害你失去一点体力",

  ["$emo__shenyong1"] = "咱家一介蒲柳,试问黄泉可留？",
  ["$emo__shenyong2"] = "天下之大，竟无吾等容身之处…",
}

skel:addEffect(fk.GameStart, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = room:getOtherPlayers(player, false)
    if #targets == 0 then return false end
    local tos = room:askToChoosePlayers(player, {
      min_num = 1, max_num = 1, targets = targets, skill_name = skel.name, cancelable = false,
      prompt = "#emo__shenyong-choose",
    })
    if #tos > 0 then
      event:setCostData(self, {tos = tos})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    room:handleAddLoseSkills(to, "emocp__tianming")
  end,
})

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) then return end
    local ids = {}
    for _, move in ipairs(data) do
      if move.from == player and move.moveReason == fk.ReasonDiscard then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
            table.insert(ids, info.cardId)
          end
        end
      end
    end
    if #ids == 2 and Fk:getCardById(ids[1]).color == Fk:getCardById(ids[2]).color then
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "ice__slash", skill_name = skel.name, cancelable = false, prompt = "#emo__shenyong-slash",
    })
    if not use then return end
    if not use.damageDealt and not player.dead then
      room:loseHp(player, 1, skel.name)
    end
  end,
})

return skel
